<template>
  <div id="main" @touchstart.stop="hidkey">
    <div class="top-box">
      <img @touchstart.stop="gobackmybooklist" class="left-arrow" src="@/assets/书城/shape_u112.png" alt />
      <span>新建书单</span>
      <span>保存</span>
    </div>
    <div class="midbox">
      <p @touchstart.stop="inputfont">
        <input type="text" placeholder="给书单起个名字吧!" />
      </p>
    </div>
    <div class="bottombox">
      <p>添加书籍</p>
      <ul>
        <li class="addbtn" @touchstart="showbox">
          <span>+</span>
        </li>

        <li v-for="(item,index) in chosedbooklist" :key="index">
          <img class="imgbook" :src="item" alt />
          <p @touchstart="delimgbook">删除</p>
        </li>
      </ul>
    </div>
    <div class="hidbox" v-show="showbookbox">
      <div class="top-nav">
        <span @touchstart="hiddingbox">取消</span>
        <span>最近照片</span>
        <div></div>
      </div>
      <ul>
        <li v-for="(value,key,index) in latebook" :key="index" @touchstart="addbook">
          <div class="bookimg">
            <img :src="value.img" alt />
            <div class="circle"></div>
            <div></div>
          </div>
          <p>{{value.name}}</p>
        </li>
      </ul>
      <div @touchstart="hiddingbox" class="confirmbox">确认</div>
    </div>
    <div class="key" :class="{movekey:showkey}"><img src="@/assets/书城/位图_u3697.png" alt=""></div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      showbookbox: false,
      showkey:false,
      latebook: {
        book1: {
          img: require("@/assets/书架/1_u4074.png"),
          name: "浮木"
        },
        book2: {
          img: require("@/assets/书架/3_u4078.png"),
          name: "浮木"
        },
        book3: {
          img: require("@/assets/书架/6_u4083.png"),
          name: "浮木"
        }
      },
      chosedbooklist: []
    };
  },
  methods: {
    gobackmybooklist(){
        this.$router.push({
            path:'/bookslist'
        },()=>{})
    },
    inputfont(){
        this.showkey=true
        console.log(this.showkey)
    },
    hidkey(){
        this.showkey=false
        console.log(this.showkey)
    },
    hiddingbox() {
      this.showbookbox = false;
    },
    showbox() {
      if (this.showbookbox == false) {
        this.showbookbox = true;
      } else {
        this.showbookbox = false;
      }
    },
    addbook(event) {
      if (event.target.parentNode.lastChild.classList == "mask") {
        event.target.parentNode.lastChild.classListNaNpxove("mask");
        event.target.parentNode.children[1].classListNaNpxove("fullcircle");
        this.chosedbooklist.splice(-1, 1);
      } else {
        event.target.parentNode.lastChild.classList.add("mask");
        event.target.parentNode.children[1].classList.add("fullcircle");
        this.chosedbooklist.push(event.target.getAttribute("src"));
      }
    },
    delimgbook(event) {
      let father = event.target.parentNode;
      fatherNaNpxove()
    }
  }
};
</script>

<style lang="less" scoped>
#main {
  width: 100%;
  .hidbox {
    width: 100%;
    height: 100%;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 99;
    background: inherit;
    background-color: rgba(255, 255, 255, 1);
    transition: all 1s linear;
    .top-nav {
      position: relative;
      margin-top: 5rem;
      height: 2.3rem;
      span {
        &:first-of-type {
          position: absolute;
          left: 1.5rem;
        }
        &:last-of-type {
          position: absolute;
          left: 50%;
          transform: translate(-50%);
        }
      }
    }
    ul {
      list-style: none;
      display: flex;
      margin-top: 1.5rem;
      li {
        margin-right: .2rem;
        margin-bottom: .5rem;
        .bookimg {
          position: relative;
          img {
            width: 8.9rem;
            height: 13rem;
          }
          .circle {
            width: 1.5rem;
            height: 1.5rem;
            border: .1rem solid white;
            border-radius: 50%;
            position: absolute;
            top: 0;
            right: .5rem;
            z-index: 99;
          }
          .fullcircle {
            background-color: white;
          }
          .mask {
            width: 8.9rem;
            height: 13rem;
            background: inherit;
            background-color: rgba(51, 51, 51, 0.4);
            position: absolute;
            top: 0;
            left: 0;
            z-index: 98;
          }
        }

        p {
          font-family: "PingFangSC-Regular", "PingFang SC";
          font-weight: 400;
          font-style: normal;
          font-size: 1.4rem;
          text-align: left;
        }
      }
    }
    .confirmbox {
      width: 34.4rem;
      height: 4.4rem;
      background: inherit;
      background-color: rgba(40, 208, 148, 1);
      border: none;
      border-radius: 2rem;
      position: absolute;
      bottom: 3.5rem;
      left: 50%;
      transform: translate(-50%);
      font-size: 1.4rem;
      color: #ffffff;
      font-family: "ArialMT", "Arial";
      font-weight: 400;
      font-style: normal;
      text-align: center;
      line-height: 4.4rem;
    }
  }

  .top-box {
    box-sizing: border-box;
    width: 100%;
    height: 1.6rem;
    display: flex;
    justify-content: space-between;
    background-color: rgba(255, 255, 255, 1);
    padding: 0 1.5rem;
    padding-top: 1.5rem;
    padding-bottom: 2.5rem;
    height: 5rem;
    position: fixed;
    top: 0;
    left: 0;
    border-bottom: .1rem solid #f2f2f2;
    img {
      margin-top: .5rem;
    }
    .left-arrow {
      width: .9rem;
      height: 1.4rem;
    }
    span {
      &:first-of-type {
        font-family: "PingFangSC-Semibold", "PingFang SC Semibold",
          "PingFang SC";
        font-weight: 650;
        font-style: normal;
        font-size: 1.8rem;
      }
      &:last-of-type {
        font-family: "PingFangSC-Regular", "PingFang SC";
        font-weight: 400;
        font-style: normal;
        color: #13d4c8;
        font-size: 1.4rem;
        text-align: left;
      }
    }
  }
  .midbox {
    margin-top: 5rem;
    padding: 0 1.5rem;
    padding-top: 1rem;
    p {
      padding-bottom: 1rem;
      border-bottom: .1rem solid rgba(242, 242, 242, 1);
      input {
        border: none;
        width: 21.2rem;
        height: 4rem;
        padding: .1rem 0rem .1rem 0rem;
        box-sizing: border-box;
        background-color: transparent;
        font-weight: 400;
        text-align: left;
        border-color: transparent;
        outline-style: none;
        font-size: 1.4rem;
        color: rgb(204, 204, 204);
        &::placeholder {
          font-size: 1.4rem;
          color: rgb(204, 204, 204);
        }
      }
    }
  }
  .bottombox {
    margin-top: 2rem;
    padding: 0 1.5rem;
    p {
      font-family: "PingFangSC-Regular", "PingFang SC";
      font-weight: 400;
      font-style: normal;
      font-size: 1.4rem;
      margin-bottom: 1rem;
    }
    ul {
      list-style: none;
      display: flex;
      flex-wrap: wrap;
      li {
        position: relative;
        .imgbook {
          width: 7rem;
          height: 7rem;
        }
        p {
          width: 7rem;
          height: 1.65rem;
          font-size: 1.2rem;
          color: #ffffff;
          font-family: "ArialMT", "Arial";
          font-weight: 400;
          font-style: normal;
          text-align: center;
          line-height: 1.65rem;
          position: absolute;
          bottom: -0.7rem;
          left: 0;
          background: inherit;
          background-color: rgba(51, 51, 51, 0.498039215686275);
          border: none;
          border-radius: 0rem;
          z-index: 10;
        }
      }
      li {
        margin-bottom: 1rem;
        margin-right: .5rem;
      }
      .addbtn {
        width: 7rem;
        height: 7rem;
        background: inherit;
        background-color: rgba(242, 242, 242, 1);
        border: none;
        border-radius: .3rem;
        font-size: 2.8rem;
        color: #999999;
        line-height: 1.8rem;
        font-weight: bold;
        position: relative;
        span {
          position: absolute;
          left: 50%;
          top: 50%;
          transform: translate(-50%, -50%);
        }
      }
    }
  }
  .key{
    position: fixed;
    bottom: -50rem;
    img{
        width: 100%;
    }
  }
  .movekey{
    animation:mykey 0.5s linear forwards;
  }
  @keyframes mykey {
    0%{
        bottom: -50rem;
    }
    100%{
        bottom: 0rem;
    }
  }
}
</style>